package com.intct.hbase.ddl.service.impl;

import com.intct.hbase.ddl.service.AbstaractHBaseDDL;
import org.apache.hadoop.hbase.client.Admin;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

/**
 * @author gufg
 * @since 2025-08-05 10:36
 */
public class DropNamespaceImpl extends AbstaractHBaseDDL {

    private String namespace;

    public DropNamespaceImpl(String namespace) {
        this.namespace = namespace;
    }

    @Override
    public void execCommand(Admin admin) {
        try {
            List<String> namespaces = Arrays.asList(admin.listNamespaces());

            if (namespaces.contains(namespace)) {
                admin.deleteNamespace(namespace);
            } else {
                System.out.println("ddddd");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) throws IOException {
        DropNamespaceImpl dropNamespace = new DropNamespaceImpl("intct83_api_1");
        dropNamespace.start();
    }
}
